/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package selection;

/**
 *选择排序算法
 * 排除已经排好顺序的 每次寻找的最小的放到最前面
 * @author root
 */
public class MySelection {
    public static int[] mySelect(int[] a){
        int i,j,flat=0;
        int tmp=0;
        for(i=0;i<a.length;i++){
            tmp = a[i];
            for(j=i+1;j<a.length;j++){
                if(tmp<a[j]){
                    flat = j;
                    tmp = a[j];
                }
            }
            if(flat !=i){
                a[flat] = a[i];
                a[i] = tmp;
            }
        }
        return a;
    }
}
